<?php
class Wmp_View_Helper_WmpLangMenu extends Zend_View
{
	public function WmpLangMenu()
    {
    	
    	//OPTIMIZEME:trouver un meilleur moyen de recuperer l'object view et fc
    	$viewRenderer =  Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
		$view = $viewRenderer->view;
    	$fc = Zend_Controller_Front::getInstance();
		$request	=$fc->getRequest();
		
		if($request->getParam('error_handler'))
			return;
		
		//$request->setParam(array('language'=>'fr'));
		//return $request->getRequestUri();	
			
		$requestArray = (array)$request->getParams();
		$requestArray['language']='fr';

		//OPTIMIZEME : trouver un moyen plus simple pour le menu multilang
		$frUrl = array(); 
		foreach($requestArray as $key => $val)
			if(is_string($val))
				$frUrl[$key]=$val;
		$frUrl = $view->url($frUrl);
		
		$requestArray['language']='en';
		
		$enUrl = array(); 
		foreach($requestArray as $key => $val)
			if(is_string($val))
				$enUrl[$key]=$val;				
		$enUrl = $view->url($requestArray);
			
        $langMenu='<div id="navmenu">
        			<a href="'.$frUrl.'" >'.$view->WmpImg('fr-lang-icon.png','Wmp framework lang fr',false,'border="0"').'</a>
        			<a href="'.$enUrl.'" >'.$view->WmpImg('en-lang-icon.png','Wmp framework lang en',false,'border="0"').'</a>        			
        		</div>';
       	return $langMenu;
    }
}
